package com.htgd.gardenexpo.dao;

import com.htgd.gardenexpo.entity.GeConLeisureDataDeck;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.htgd.gardenexpo.vo.MileageDurationTrackVO;
import com.htgd.gardenexpo.vo.MySportsRecordVO;
import com.htgd.gardenexpo.vo.MyTaskDetails;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 挑战甲板数据 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-04-03
 */
public interface GeConLeisureDataDeckMapper extends BaseMapper<GeConLeisureDataDeck> {
    @Select("SELECT COALESCE(SUM(mileage), 0)  FROM `ge_con_leisure_data_deck` WHERE deck_id = #{deckId}")
    double getSumMileageByOpenId(@Param("deckId") String deckId);
    @Select("SELECT COALESCE(SUM(mileage), 0) FROM `ge_con_leisure_data_deck` WHERE deck_id =#{deckId} and begin_time like CONCAT(#{date},'%')")
    double getSumMileageByDeckIdAndDate(@Param("deckId")String deckId, @Param("date") String date);
    @Select("SELECT COALESCE(SUM(duration), 0)  FROM `ge_con_leisure_data_deck` WHERE deck_id = #{deckId}")
    double getSumDurationByDeckId(@Param("deckId") String deckId);

    List<MySportsRecordVO> getSportsRecord(@Param("deckId") String deckId);
    @Select("SELECT * FROM `ge_con_leisure_data_deck` WHERE task_id = #{taskId} ORDER BY end_time DESC LIMIT 1")
    GeConLeisureDataDeck getEndRecord(@Param("taskId") String taskId);

    MileageDurationTrackVO getDataByTaskId(@Param("taskId") String taskId);

    MyTaskDetails getTaskDetails(@Param("taskId") String taskId);
}
